# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/14 19:39
# @Author   : Robot-Zsj
"""
description:

i:
6 2 7 7 9 3 2 1 3 11 4
2

o:
28
"""
balls = list(map(int, input().split()))
n = int(input())


def check(index, buckets, limit):
    if index == len(balls):
        return True
    selected = balls[index]

    for i in range(len(buckets)):

        if i > 0 and buckets[i] == buckets[i - 1]:
            continue

        if selected + buckets[i] <= limit:
            buckets[i] += selected
            if check(index + 1, buckets, limit):
                return True
            buckets[i] -= selected
    return False


def getResult():
    balls.sort(reverse=True)

    low = balls[0]
    high = sum(balls)

    ans = high

    while low <= high:
        mid = (low + high) >> 1

        if check(0, [0] * n, mid):
            ans = mid

            high = mid - 1
        else:
            low = mid + 1

    return ans


print(getResult())
